package test;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public class CopyOfUrlConnectionTest2 {

	public static void main(String[] args) throws Exception{
		String body="cname=abddeffafsf&sal=23.00&birth=2017-07-04&sex=true";
		URL url=new URL("http://localhost:8080/EasyCrmPlus/add");
		URLConnection con=url.openConnection();
		HttpURLConnection hcon=(HttpURLConnection)con;
		hcon.setRequestMethod("POST");
		hcon.setDoOutput(true);
		OutputStream out=hcon.getOutputStream();
		out.write(body.getBytes());
		
		int len=hcon.getContentLength();
		InputStream in=hcon.getInputStream();
		byte[] buf=new byte[len];
		in.read(buf);
		in.close();
		hcon.disconnect();
		System.out.println(new String(buf));
//cname=addf&sal=23.00&birth=2017-07-04&sex=true
	}

}
